<?php
header('Content-type: text/xml');
require_once('../../isa-lib/nusoap/nusoap.php');
include "../../isa-lib/isa-function/isa_public_function.php";
include "../../onegate_function.php";
include "../../db_const.php";
include "../../isa-lib/adodb/adodb.inc.php";
include "../../isa-lib/isa-function/prax.php";
include "../../connect_ado.php";
include "rss_function.php";
include "const.php";
//Lay danh sach cac bang bieu so lieu
$v_is_view_record_on_net = 1;
include "../../record/record-lib/qry_all_recordtype_by_staff.php";
//Lay danh sach ho ho so dang thu ly
$v_detail_status_compare = " And C_DETAIL_STATUS <> 51";
$v_status_list = "CAP_PHEP";
$v_recordtype_filter = '';
include "qry_all_record.php";
/**********************************************************************************/
$strXML = '<?xml version="1.0" encoding="utf-8"?><rss version="2.0">';
$strXML = $strXML . '<channel>';
$strXML = $strXML . '<title>'.CONST_CHANNEL_SOLVED_RECORD_TITLE.'</title>';
$strXML = $strXML . '<link>'._get_current_website_path().'/record/view/index.php</link>';
$strXML = $strXML . '<description></description>';
$strXML = $strXML . '<category></category>';
for ($index=0;$index<sizeof($arr_all_recordtype);$index++){
	$v_file_list = 'danh_sach_ho_so_da_tiep_nhan.xml';
	$v_colume_value_of_xml_string = 'C_RECEIVED_RECORD_XML_DATA';
	$v_title_list = $arr_all_recordtype[$index]['1'];
	$v_recordtype_filter = $arr_all_recordtype[$index]['0'];
	$v_count = sizeof($arr_all_record);
	$arr_all_record_temp = array();
	$j=0;
	for ($i=0;$i<$v_count;$i++){
		if ($arr_all_record[$i]['FK_RECORDTYPE'] == $v_recordtype_filter){
			$arr_all_record_temp[$j] = $arr_all_record[$i];
			$j++;
		}
	}
	//file dinh dang bang hien thi danh sach ho so da tiep nhan
	$v_table_struct_xml_file = "../../xml/".$v_recordtype_filter."/".$v_file_list;
	if (file_exists($v_table_struct_xml_file)){
		$v_table_struct_xml_string = _read_file($v_table_struct_xml_file);
	}else{
		$v_table_struct_xml_file = "../../xml/other/".$v_file_list;
		$v_table_struct_xml_string = _read_file($v_table_struct_xml_file);
	}
	$v_html_content = Generate_Record_List($arr_all_record_temp,$v_table_struct_xml_string,$v_title_list,$v_colume_value_of_xml_string);
	//Bat dau tao ra cac phan tu cua danh sach
	$strXML = $strXML . '<item>';
	$strXML = $strXML . '<title>'.$v_title_list.'</title>';
	$strXML = $strXML . '<link></link>';
	$strXML = $strXML . '<description></description>';
	$strXML = $strXML . '<html_content>'.htmlspecialchars($v_html_content).'</html_content>';
	$strXML = $strXML . '<file_content></file_content>';
	$strXML = $strXML . '</item>';
	
}
$strXML = $strXML . '</channel>';
$strXML = $strXML . '</rss>';
print($strXML);
//Ham tra ve duong dan dang ung dung
function _get_current_website_path(){
	global $_SERVER;
	$v_website_path = $_SERVER["SCRIPT_NAME"];
	$arr_website_path = explode("/",$v_website_path);
	if ($arr_website_path[1]!=""){
		$v_current_website_path = 'http://'.$_SERVER['HTTP_HOST'].'/'.$arr_website_path[1];
	}else{
		$v_current_website_path = 'http://'.$_SERVER['HTTP_HOST'];
	}
	return $v_current_website_path;
}	
?>
